<?php

class ProjectsController extends Controller
{
	public $layout = "projects/main";
	public function actionIndex()
        {   
        	$userId = Yii::app()->user->id;
            $projectUsers = ProjectUser::model()->findAllByAttributes(array('project_user_user_id'=>$userId));
            $projects = array();
            foreach ($projectUsers as $projectUser) {
               $project = $projectUser->projectUserProject;
               $projectLink = $this->createUrl("/dashboard/index", array('pid'=>$project->project_id));
               $projects[] = array(
                   'projectLink'  => $projectLink,
                   'projectName' => $project->project_name,
               );
            }
			$this->render('index',array(
                            'projects' => $projects,
                        )
                );
	}

	// -----------------------------------------------------------
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}